﻿Public Class CKiemTra
    Shared da As DataProvider
    Public Shared Function LoadDS(ByVal sql As String) As DataTable
        Try
            da = New DataProvider
            da.OpenConnect()
            Return da.ShowData(sql)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Thông báo")
            Return Nothing
        Finally
            da.CloseConnect()
        End Try
    End Function
    Public Shared Sub Insert(ByVal sql As String)
        Try
            da = New DataProvider
            da.OpenConnect()
            Dim cmd As New SqlClient.SqlCommand(sql, da.con)
            cmd.ExecuteNonQuery()
            MsgBox("Thêm thành công", MsgBoxStyle.Information, "Thông báo")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Thông báo")
        Finally
            da.CloseConnect()
        End Try
    End Sub
    Public Shared Sub Delete(ByVal sql As String)
        Try
            da = New DataProvider
            da.OpenConnect()
            Dim cmd As New SqlClient.SqlCommand(sql, da.con)
            cmd.ExecuteNonQuery()
            MsgBox("Xóa thành công", MsgBoxStyle.Information, "Thông báo")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Thông báo")
        Finally
            da.CloseConnect()
        End Try
    End Sub
    Public Shared Sub Update(ByVal sql As String)
        da = New DataProvider
        da.SqlExcuteNonQuery(sql)
    End Sub
End Class
